package com.lmf.annotation.bean;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

//类自定义管理生命周期，方式二： 重写两个类的初始化，销毁方法，默认对象单实例
@Scope("prototype") //多实例
@Component
public class Dog implements InitializingBean, DisposableBean {
    public Dog() {
        System.out.println("Dog类被创建");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("Dog类被销毁");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("Dog类属性已经被初始化完成");
    }
}
